package top.likeqc.leetcode.editor.cn;

import java.util.HashMap;

public class TwoSum {
    public static void main(String[] args) {
        Solution solution = new TwoSum().new Solution();
    }
    
    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int[] twoSum(int[] nums, int target) {
            HashMap<Integer, Integer> map = new HashMap<>();
            for (int i = 0; i < nums.length; i++) {
                Integer index = map.get(target - nums[i]);
                if(index != null && index != i) {
                    return new int[]{index, i};
                }
                map.put(nums[i], i);
            }
            return null;
        }
    }
    //leetcode submit region end(Prohibit modification and deletion)
    
}